package md.mru.backend.core.service;

import md.mru.backend.common.BaseDtoMapper;
import md.mru.backend.core.domains.FamilyStatus;
import md.mru.backend.core.domains.Nationality;
import md.mru.backend.core.dtos.FamilyStatusDto;
import md.mru.backend.core.dtos.NationalityDto;
import md.mru.backend.core.repositories.FamilyStatusRepository;
import md.mru.backend.core.repositories.NationalityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sergiu.marin
 * @since 01.04.2014
 */
@Service
public class ApplicationDataService {

    @Autowired
    @Qualifier(value = "dtoMapper")
    private BaseDtoMapper mapper;
    @Autowired
    private NationalityRepository nationalityRepository;

    @Autowired
    private FamilyStatusRepository familyStatusRepository;

    public List<NationalityDto> getNationalities() {
        List<Nationality> nationalities = nationalityRepository.findAll();
        return mapper.mapList(nationalities, NationalityDto.class);
    }

    public List<FamilyStatusDto> getFamilyStatuses() {
        List<FamilyStatus> familyStatuses = familyStatusRepository.findAll();
        return mapper.mapList(familyStatuses, FamilyStatusDto.class);
    }

}
